// JavaScript原型和继承 http://blog.jobbole.com/19795/
// 代码实践

function outputObj(obj) {
    var description = "";
    for (var i in obj) {
        description += i + " = " + obj[i] + "\n";
    }
    return description;
}

// 构造函数的演示
function A() {};
console.log("A.constructor = " + A.constructor);
console.log("A.prototype = " + A.prototype);
// A 的原型 的 构造函数指向了 A
console.log("A.prototype.constructor = " + A.prototype.constructor);



function B() {
    this.width = 10;
    this.data = [1,2,3];
    this.key = "this is A";
};
B._objectNum = 0;//定义A的属性
B.prototype.say = function(){//给A的原型对象添加属性
    alert("hello world")
}

console.log("B.attrs = " + outputObj(B))
console.log("B = " + B)
console.log("B.prototype = " + B.prototype);
var b = new B();
// console.log("b = " + Object.prototype.toString.call(b));
console.log("b = " + JSON.stringify(b));


